package org.red_cross_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.red_cross_service.domain.entity.ActivityEntity;
import org.red_cross_service.domain.vo.AvtivityVO;

import java.util.List;

public interface ActivityMapper extends BaseMapper<ActivityEntity> {
    @Select("select * from rc_activity \n" +
            "where current_timestamp between activity_begin_time and activity_end_time;"
    )
    List<AvtivityVO> getUserActivities(Integer userId);
    @Select("select * from rc_activity \n" +
            "where current_timestamp > activity_end_time")
    List<AvtivityVO> getUserPassActivities(Integer userId);

    @Select("select * from rc_learn_record l \n" +
            " right join rc_activity a on l.activity_id = a.activity_id and l.user_id=#{userId}" +
            " where a.activity_id = #{activityId}")
    AvtivityVO getUserOneActivity(Integer activityId, Integer userId);
}
